<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('库存统计报表')" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.tables.js" type="text/javascript"></script>
<body id="colTb" style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">产品编码</label>
                        <input type="text" class="layui-input" name="goodsBh" id="goodsBh" placeholder="请输入产品编码" />
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">产品名称</label>
                        <input type="text" class="layui-input" name="goodsMc" id="goodsMc" placeholder="请输入产品名称" />
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal search_btn" lay-event="searchEvent" data-type="reload">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-normal">重置</button>
                    </div>
                </form>
                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar"></div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body">
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>
<script th:inline="javascript">
    var functions = [[${functions}]];
    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };
    layui.use(['list', 'layer', 'zzpUtils', 'jquery', 'laydate', 'tablebutton'], function () {
        var myColumns = [];
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                searchEvent: function(){
                    zzpUtils.refreshTable("#table");
                },
                /*导出*/
                exportEvent: function (data) {
                    var arr = [];
                    var $rows = $table.bootstrapTable('getSelections');
                    if ($rows.length > 0) {
                        arr = $.map($rows, function (row) {
                            console.log(row);
                            return row.goodsId;
                        })
                    }
                    /*
                     * 以下是将ids和对象拼接在一起
                     * */
                    var str = zzpUtils.getFormJson($("#searchForm"));
                    var object2 = Object.assign({ids: arr}, str);
                    /*将条件查询和ids传到后台*/
                    zzpUtils.outputXslx({
                        url: "/statistics/stockStatisticsExport",
                        data: JSON.stringify(object2)
                    });
                }
            }
        });
        //初始化
        zzpUtils.webSocket.init();
        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/statistics/stockStatistics',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'goodsNc',
                title: 'NC编码'
            },{
                field: 'goodsBh',
                title: '产品编码'
            },{
                field: 'goodsMc',
                title: '产品名称'
            },{
                field: 'goodsGg',
                title: '规格',
            },{
                field: 'dw',
                title: '单位',
            },{
                field: 'je',
                title: '单价',
            },{
                field: 'hppc',
                title: '产品批次',
            },{
                field: 'hpdj',
                title: '产品等级',
            },{
                field: 'ccqsl',
                title: '存储区数量',
            },{
                field: 'jhqsl',
                title: '分拣区数量',
            },{
                field: 'zsl',
                title: '总数量',
            },{
                field: 'zje',
                title: '总货值',
            }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },

        });
    })

</script>
</html>